//
//  HomeViewController.swift
//  MyVideo
//
//  Created by han on 2021/4/20.
//

import UIKit

class HomeViewController: UITableViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        
    }
}

extension HomeViewController {
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        switch indexPath.row {
        case 0:
            pushToUsingAVKit()
        case 1:
            pushToSimplePlayer()
        case 2:
            pushToPlaybackLongFormVideoIntegratingAirPlay()
        case 3:
            pushToPersistStreamsDownload()
        case 4:
            pushToAudio()
        default:
            break
        }
    }
    
    func pushToUsingAVKit() {
        let usingAVKit = UIStoryboard(name: "UsingAVKit", bundle: nil).instantiateViewController(identifier: UsingAVKitViewController.storyboardID) as! UsingAVKitViewController
        navigationController?.pushViewController(usingAVKit, animated: true)
    }
    
    func pushToSimplePlayer() {
        let vc = UIStoryboard(name: "SimplePlayer", bundle: nil).instantiateViewController(identifier: SimplePlayerViewController.storyboardID) as! SimplePlayerViewController
        navigationController?.pushViewController(vc, animated: true)
    }
    
    func pushToPlaybackLongFormVideoIntegratingAirPlay() {
        let vc = UIStoryboard(name: "SimplePlayer", bundle: nil).instantiateViewController(identifier: AirPlayViewController.storyboardID) as! AirPlayViewController
        navigationController?.pushViewController(vc, animated: true)
    }
    
    func pushToPersistStreamsDownload() {
        let vc = UIStoryboard(name: "Persist", bundle: nil).instantiateViewController(identifier: PersistListViewController.storyboardID) as! PersistListViewController
        navigationController?.pushViewController(vc, animated: true)
    }
    
    func pushToAudio() {
        let vc = UIStoryboard(name: "Audio", bundle: nil).instantiateViewController(identifier: AudioSampleBufferPlayerViewController.storyboardID) as! AudioSampleBufferPlayerViewController
        navigationController?.pushViewController(vc, animated: true)
    }
}
